<!DOCTYPE>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<from class="layui-form" action="" id="fromAdd">
    <div class="layui-form-item">

        <div class="layui-inline">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input type="hidden" name="id" id="id" th:value="${admin.id}">
                <input type="tel" name="username" id="username" th:value="${admin.username}"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="text" name="password" id="password" th:value="${admin.password}"  autocomplete="off" class="layui-input">
            </div>
        </div>

    </div>

    <div class="layui-form-item">

        <div class="layui-inline">
            <label class="layui-form-label">身份</label>
            <div class="layui-input-inline">
                <input type="tel" name="identity" id="identity" th:value="${admin.identity}"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-inline">
                <input type="text" name="state" id="state" th:value="${admin.state}"  autocomplete="off" class="layui-input">
            </div>
        </div>

    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" onclick="doSave();" class="layui-btn"  lay-filter="demo1">立即提交</button>
        </div>
    </div>
</from>

<script>
    var $,layer;
    layui.use(['form','laydate'],function (){
        var laydate = layui.laydate;
        $ = layui.jquery;
        layer = layui.layer;
        //日期
        laydate.render({
            elem:'#laydate'
        });
    })

    function doSave(){
        //alert("vvv");
        $.ajax({
            type:"post",
            url:"/stuinfo/update",
            data:{
                id:$("#id").val(),
                username:$("#username").val(),
                password:$("#password").val(),
                identity:$("#identity").val(),
                state:$("#state").val()

            },
            success:function (data){
                if (data.success == 1){
                    layer.alert("修改成功",{yes:function (){
                        parent.layer.closeAll();
                        }})
                }else{
                    layer.alert("修改失败",{yes:function (){
                            parent.layer.closeAll();
                        }})
                }
            },
            error:function (){

            }

        })
    }
</script>
</body>
</html>